const friend = require('./controller/login')
const Route = require('koa-router')
const learningSpace = new Route({ prefix: '/learningSpace' })
const table = new Route({ prefix: '/table' })
const user = new Route({ prefix: '/user' })
const userControl = require('./controller/usercontrol')
const admin = require('./routes/admin')
const register = require('./controller/register')
const recommend = require('./controller/table')

const fileControl = require('./controller/filecontrol')

module.exports = (app) => {
  table.get('/firstRecommend', recommend.coldRecommend)
  table.get('/recommend', recommend.recommend)
  user.get('/userinfo', userControl.getInfo)
  user.post('/upload', fileControl.upload)
  user.post('/download', fileControl.send)
  user.get('/file', fileControl.show)
  user.patch('/passwordChange', userControl.passwordChange)
  learningSpace.post('/login', friend.login)
  learningSpace.post('/register', register)
  learningSpace.post('/learnStyle', userControl.saveStyle)
  learningSpace.use(table.routes()).use(table.allowedMethods())
  learningSpace.use(user.routes()).use(user.allowedMethods())
  learningSpace.use(admin.routes()).use(admin.allowedMethods())
  app.use(learningSpace.routes()).use(learningSpace.allowedMethods())
}
